<template>
  <div class="bg">
    <!-- 中间的盒子 -->
    <div class="centerBox">
      <!-- 标题 -->
      <div class="titleBox">医院预约挂号系统</div>
      <!-- 用户名 -->
      <div style="margin-bottom: 20px;">
        <el-input v-model="username" placeholder="请输入用户名">
          <template slot="prepend">
            <i class="el-icon-user"></i>
          </template>
        </el-input>
      </div>
      <!-- 密码 -->
      <div style="margin-bottom: 20px;">
        <el-input v-model="password" placeholder="请输入密码" show-password="false">
          <template slot="prepend">
            <i class="el-icon-lock"></i>
          </template>
        </el-input>
      </div>

      <div style="margin-bottom: 20px; text-align: center">
        <el-radio v-model="radio" label="ADMIN">管理员</el-radio>
        <el-radio v-model="radio" label="DOCTOR">医生</el-radio>
        <el-radio v-model="radio" label="USER">患者</el-radio>
      </div>
      <!-- 注册 -->
      <div style="text-align: center; margin-bottom: 20px;">
        <el-button type="primary" style="width: 100%;" @click="register">立即注册</el-button>
      </div>

      <!-- 返回登录页面 -->
      <div class="login" @click="login()">
        <!-- <a href="http://localhost:8080/login">返回登录</a> -->
        返回登录
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import request from "@/utils/request";
export default {
  data() {
    return {
      username: "",
      password: "",
      radio: "USER"
    };
  },
  methods: {
    //登录按钮
    register() {
      // alert("登录")
      //发送请求
      request.post("/login/register?account=" + this.username +
          "&password=" +
          this.password +
          "&role=" +
          this.radio).then(res => {
        if(res.code == 200){
          this.$message({
            message:"注册成功!",
            type:"success"
          })
          this.$router.replace({path:'/login'})
        }else{
          this.$message({
            message: res.msg,
            type: "error"
          });
        }
      })
    },

    //返回login
    login(){
      this.$router.push({path:'/login'})
    }


  }
};
</script>

<style>
.bg {
  height: 100vh;
  background-color: #c9e3fa;
  overflow: hidden;
}
.bg .centerBox {
  margin: 200px auto;
  width: 360px;
  height: 320px;
  background-color: #c9e3fa;
}
.titleBox {
  height: 70px;
  line-height: 70px;
  color: #1e90ff;
  font-weight: 800;
  font-size: 26px;
  text-align: center;
}
.login {
  float: right;
}
.login {
  text-decoration: none;
  color: #958b2f;
}
.forgetPassword a {
  text-decoration: none;
  color: #958b2f;
}
</style>